# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=slidge
pkgver=0.1.3
pkgrel=0
pkgdesc="XMPP puppeteering gateway framework"
url="https://slidge.im/"
arch="noarch"
license="AGPL-3.0-or-later"
depends="
	py3-aiohttp
	py3-blurhash
	py3-configargparse
	py3-magic
	py3-numpy
	py3-pickle-secure
	py3-pillow
	py3-qrcode
	py3-slixmpp
	"
makedepends="
	py3-gpep517
	py3-poetry-core
	"
checkdepends="
	py3-pytest
	py3-pytest-asyncio
	py3-xmldiff
	"
install="$pkgname.pre-install"
pkgusers="slidge"
pkggroups="slidge"
subpackages="$pkgname-doc $pkgname-openrc $pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://git.sr.ht/~nicoco/slidge/archive/v$pkgver.tar.gz
	slidge.initd
	slidge.confd
	common.conf.example
	"
builddir="$srcdir/$pkgname-v$pkgver"

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m pytest --log-level WARNING
}

package() {
	python3 -m installer -d "$pkgdir" .dist/*.whl

	install -dm750 -o slidge -g slidge \
		"$pkgdir"/etc/slidge \
		"$pkgdir"/etc/slidge/conf.d \
		"$pkgdir"/var/lib/slidge \
		"$pkgdir"/var/log/slidge

	install -Dm640 -o slidge -g slidge -t "$pkgdir"/etc/slidge/conf.d/ \
		"$srcdir"/common.conf.example

	install -Dm644 -t "$pkgdir"/usr/share/doc/$pkgname/examples/ \
		docs/source/admin/examples/ejabberd.yaml \
		docs/source/admin/examples/prosody.cfg.lua \
		dev/confs/*

	install -Dm755 "$srcdir"/slidge.initd "$pkgdir"/etc/init.d/slidge
	install -Dm644 "$srcdir"/slidge.confd "$pkgdir"/etc/conf.d/slidge
}

sha512sums="
793ba99f271a4f8569f0f99dd720d929d77a9b7a078f8f36c10f047ca16fd8b1348715558c5139c04e1a7bcaaaad49a93ad0ad28328c038a74251a4464c39c08  slidge-0.1.3.tar.gz
a0a9f2578060dac366dc5198dfd6481f869dc225ba7da0bfaf9213382f7e08fdebe965418ba287dce60a0e1b01433ce8430de52574b2f16b335059383147eb76  slidge.initd
27dac3c86b047012c4c835cffb497ad8aa059a69d03b6fa0ca3368222a3fcb929f181c8aac3edf25d2081d32f06673256d22f17ad3c55cae87493533a5115053  slidge.confd
a67660cb0f1be38187affa998c0ba41fed5f8b48da82dea28849b8ead855fd4ab244952020ae2509a313f0bb0e6590cb2a4fdc2d6f264919fbf9430be9bf6cc4  common.conf.example
"
